package com.azlogica.control;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.azlogica.gpslocation.MainActivity;

public class AlarmBroadcast extends BroadcastReceiver {

	@Override
	public void onReceive(Context context, Intent intent) {
		if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())){
			Intent main = new Intent(context, MainActivity.class);
			main.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			context.startActivity(main);
		}
		
		if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())){
			Intent service = new Intent(context, GpsService.class);
			service.putExtra("MESSTYPE", 6);
			context.startService(service);
		}
		
		
		if (Intent.ACTION_BATTERY_LOW.equals(intent.getAction())){
			Intent service = new Intent(context, GpsService.class);
			service.putExtra("MESSTYPE", 14);
			context.startService(service);
		}
		
		if (Intent.ACTION_SHUTDOWN.equals(intent.getAction())){
			Intent service = new Intent(context, GpsService.class);
			service.putExtra("MESSTYPE", 11);
			context.startService(service);
		}

		Intent service = new Intent(context, GpsService.class);
		service.putExtra("MESSTYPE", 1);
		context.startService(service);
	}
}